#include "els.h"
int ELSAPI_stdfile_fopen(els_VmObj* vm); // fopen(fname: str,mod: str): ptr     '以指定模式打开一个文件,mod对应C语言,失败返回null'
int ELSAPI_stdfile_fclose(els_VmObj* vm); // fclose(fp: ptr): int                '关闭一个文件,成功返回0,失败返回null'
int ELSAPI_stdfile_fputc(els_VmObj* vm); // fputc(fp: ptr,c: [int]): int        'c 的字符值写入到 fp 所指向的输出流中。如果写入成功，它会返回写入的字符，如果发生错误，则会返回 null'
int ELSAPI_stdfile_fputs(els_VmObj* vm); // fputs(fp: ptr,s: str): int          's 写入到 fp 所指向的输出流中。如果写入成功，它会返回一个非负值，如果发生错误，则会返回 null'
int ELSAPI_stdfile_fgetc(els_VmObj* vm); // fgetc(fp: ptr): int                 '函数从 fp 所指向的输入文件中读取一个字符。返回值是读取的字符，如果发生错误则返回 null' 
int ELSAPI_stdfile_finput(els_VmObj* vm); // finput(fp:ptr): str                 '从 fp 所指向文件中读取一个字段，遇到空格等结束'
int ELSAPI_stdfile_fgets(els_VmObj* vm); // fgets(fp: ptr, int n): str          '从 fp 所指向的输入流中读取 n-1 个字符"如果n为null,则读取为内核最大字符缓冲区"如果这个函数在读取最后一个字符之前就遇到一个换行符或文件的末尾 null,则只会返回读取到的字符，包括换行符'
int ELSAPI_stdfile_feof(els_VmObj* vm); // feof(fp: ptr): int                  'fp 是否到达结尾，否返回 null'
int ELSAPI_stdfile_fseek(els_VmObj* vm); // fseek(fp: ptr,i: int,sp: int):int   '设置流 fp 的文件位置为给定的偏移 i,参数i 意味着从给定的 sp 位置查找的字节数'
int ELSAPI_stdfile_ftell(els_VmObj* vm); // ftell(fp: ptr): int                 '返回文件当前位置，以文件头为相对位置' 
int ELSAPI_stdfile_rewind(els_VmObj* vm); // rewind(fp: prt): null               '返回文件头'                               
#ifdef ELS_CONF_TOKEN_EN
static const char LibScript[]={
102,105,108,101,32,61,32,123,125,10,
100,101,102,32,102,105,108,101,46,111,112,101,110,40,102,110,44,109,111,100,41,58,10,
32,32,32,32,39,39,39,10,
32,32,32,32,32,32,32,32,102,110,-26,-104,-81,-26,-106,-121,-28,-69,-74,-27,-112,-115,44,109,111,100,32,-26,-104,-81,-26,-119,-109,-27,-68,-128,-26,-88,-95,-27,-68,-113,10,
32,32,32,32,32,32,32,32,109,111,100,32,-26,-104,-81,-28,-72,-114,67,-27,-121,-67,-26,-107,-80,102,111,112,101,110,-25,-102,-124,-25,-84,-84,-28,-70,-116,-28,-72,-86,-27,-113,-126,-26,-107,-80,-25,-101,-72,-27,-112,-116,-25,-102,-124,-26,-88,-95,-27,-68,-113,-27,-113,-126,-26,-107,-80,44,-27,-123,-73,-28,-67,-109,-27,-90,-126,-28,-72,-117,10,
32,32,32,32,32,32,32,32,-26,-88,-95,-27,-68,-113,32,32,32,32,32,-26,-113,-113,-24,-65,-80,10,
32,32,32,32,32,32,32,32,34,114,34,32,32,32,32,32,-26,-119,-109,-27,-68,-128,-28,-72,-128,-28,-72,-86,-25,-108,-88,-28,-70,-114,-24,-81,-69,-27,-113,-106,-25,-102,-124,-26,-106,-121,-28,-69,-74,-29,-128,-126,-24,-81,-91,-26,-106,-121,-28,-69,-74,-27,-65,-123,-23,-95,-69,-27,-83,-104,-27,-100,-88,-29,-128,-126,10,
32,32,32,32,32,32,32,32,34,119,34,9,32,32,32,32,-27,-120,-101,-27,-69,-70,-28,-72,-128,-28,-72,-86,-25,-108,-88,-28,-70,-114,-27,-122,-103,-27,-123,-91,-25,-102,-124,-25,-87,-70,-26,-106,-121,-28,-69,-74,-29,-128,-126,-27,-90,-126,-26,-98,-100,-26,-106,-121,-28,-69,-74,-27,-112,-115,-25,-89,-80,-28,-72,-114,-27,-73,-78,-27,-83,-104,-27,-100,-88,-25,-102,-124,-26,-106,-121,-28,-69,-74,-25,-101,-72,-27,-112,-116,-17,-68,-116,-27,-120,-103,-28,-68,-102,-27,-120,-96,-23,-103,-92,-27,-73,-78,-26,-100,-119,-26,-106,-121,-28,-69,-74,-25,-102,-124,-27,-122,-123,-27,-82,-71,-17,-68,-116,-26,-106,-121,-28,-69,-74,-24,-94,-85,-24,-89,-122,-28,-72,-70,-28,-72,-128,-28,-72,-86,-26,-106,-80,-25,-102,-124,-25,-87,-70,-26,-106,-121,-28,-69,-74,-29,-128,-126,10,
32,32,32,32,32,32,32,32,34,97,34,9,32,32,32,32,-24,-65,-67,-27,-118,-96,-27,-120,-80,-28,-72,-128,-28,-72,-86,-26,-106,-121,-28,-69,-74,-29,-128,-126,-27,-122,-103,-26,-109,-115,-28,-67,-100,-27,-112,-111,-26,-106,-121,-28,-69,-74,-26,-100,-85,-27,-80,-66,-24,-65,-67,-27,-118,-96,-26,-107,-80,-26,-115,-82,-29,-128,-126,-27,-90,-126,-26,-98,-100,-26,-106,-121,-28,-69,-74,-28,-72,-115,-27,-83,-104,-27,-100,-88,-17,-68,-116,-27,-120,-103,-27,-120,-101,-27,-69,-70,-26,-106,-121,-28,-69,-74,-29,-128,-126,10,
32,32,32,32,32,32,32,32,34,114,43,34,9,-26,-119,-109,-27,-68,-128,-28,-72,-128,-28,-72,-86,-25,-108,-88,-28,-70,-114,-26,-101,-76,-26,-106,-80,-25,-102,-124,-26,-106,-121,-28,-69,-74,-17,-68,-116,-27,-113,-81,-24,-81,-69,-27,-113,-106,-28,-71,-97,-27,-113,-81,-27,-122,-103,-27,-123,-91,-29,-128,-126,-24,-81,-91,-26,-106,-121,-28,-69,-74,-27,-65,-123,-23,-95,-69,-27,-83,-104,-27,-100,-88,-29,-128,-126,10,
32,32,32,32,32,32,32,32,34,119,43,34,9,-27,-120,-101,-27,-69,-70,-28,-72,-128,-28,-72,-86,-25,-108,-88,-28,-70,-114,-24,-81,-69,-27,-122,-103,-25,-102,-124,-25,-87,-70,-26,-106,-121,-28,-69,-74,-29,-128,-126,10,
32,32,32,32,32,32,32,32,34,97,43,34,9,-26,-119,-109,-27,-68,-128,-28,-72,-128,-28,-72,-86,-25,-108,-88,-28,-70,-114,-24,-81,-69,-27,-113,-106,-27,-110,-116,-24,-65,-67,-27,-118,-96,-25,-102,-124,-26,-106,-121,-28,-69,-74,-29,-128,-126,10,
10,
32,32,32,32,39,39,39,10,
10,
32,32,32,32,118,97,114,32,116,104,105,115,32,61,32,123,125,10,
32,32,32,32,10,
32,32,32,32,116,104,105,115,46,70,73,76,69,32,61,32,102,111,112,101,110,40,102,110,44,109,111,100,41,10,
32,32,32,32,105,102,32,116,104,105,115,46,70,73,76,69,32,61,61,32,110,117,108,108,32,58,32,114,101,116,117,114,110,32,110,117,108,108,32,59,10,
32,32,32,32,10,
32,32,32,32,116,104,105,115,46,102,105,108,101,110,97,109,101,32,61,32,102,110,10,
32,32,32,32,116,104,105,115,46,109,111,100,32,61,32,109,111,100,10,
32,32,32,32,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,99,108,111,115,101,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,99,108,111,115,101,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,112,117,116,99,40,105,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,112,117,116,99,40,116,104,105,115,46,70,73,76,69,44,105,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,112,114,105,110,116,40,115,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,112,117,116,115,40,116,104,105,115,46,70,73,76,69,44,115,41,10,
32,32,32,32,59,10,
10,
32,32,32,32,100,101,102,32,116,104,105,115,46,103,101,116,115,40,105,41,58,32,35,32,-24,-81,-69,-27,-113,-106,105,-28,-72,-86,-27,-83,-105,-25,-84,-90,-17,-68,-116,-28,-72,-114,102,103,101,116,115,-28,-72,-115,-28,-72,-128,-26,-96,-73,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,103,101,116,115,40,116,104,105,115,46,70,73,76,69,44,105,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,103,101,116,99,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,103,101,116,99,40,116,104,105,115,46,70,73,76,69,41,32,32,32,32,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,105,110,112,117,116,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,105,110,112,117,116,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,108,105,110,101,105,110,112,117,116,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,103,101,116,115,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,101,111,102,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,101,111,102,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,115,101,101,107,40,105,44,115,112,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,115,101,101,107,40,116,104,105,115,46,70,73,76,69,44,105,44,115,112,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,116,101,108,108,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,116,101,108,108,40,116,104,105,115,46,70,73,76,69,41,32,32,32,32,10,
32,32,32,32,59,10,
10,
32,32,32,32,114,101,116,117,114,110,32,116,104,105,115,10,
59,10,
0};
#endif
#ifdef ELS_CONF_TOKEN_CN
static const char LibScript_cn[]={
-26,-106,-121,-28,-69,-74,32,61,32,123,125,10,
100,101,102,32,-26,-106,-121,-28,-69,-74,46,-26,-119,-109,-27,-68,-128,40,102,110,44,109,111,100,41,58,10,
32,32,32,32,10,
32,32,32,32,118,97,114,32,116,104,105,115,32,61,32,123,125,10,
32,32,32,32,10,
32,32,32,32,116,104,105,115,46,70,73,76,69,32,61,32,102,111,112,101,110,40,102,110,44,109,111,100,41,10,
32,32,32,32,105,102,32,116,104,105,115,46,70,73,76,69,32,61,61,32,110,117,108,108,32,58,32,114,101,116,117,114,110,32,110,117,108,108,32,59,10,
32,32,32,32,10,
32,32,32,32,116,104,105,115,46,-26,-106,-121,-28,-69,-74,-27,-112,-115,32,61,32,102,110,10,
32,32,32,32,116,104,105,115,46,-26,-88,-95,-27,-68,-113,32,61,32,109,111,100,10,
32,32,32,32,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-27,-123,-77,-23,-105,-83,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,99,108,111,115,101,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-27,-122,-103,-27,-83,-105,-24,-118,-126,40,105,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,112,117,116,99,40,116,104,105,115,46,70,73,76,69,44,105,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-26,-119,-109,-27,-115,-80,40,115,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,112,117,116,115,40,116,104,105,115,46,70,73,76,69,44,115,41,10,
32,32,32,32,59,10,
10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-24,-81,-69,-27,-113,-106,40,105,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,103,101,116,115,40,116,104,105,115,46,70,73,76,69,44,105,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-24,-81,-69,-27,-83,-105,-24,-118,-126,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,103,101,116,99,40,116,104,105,115,46,70,73,76,69,41,32,32,32,32,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-24,-66,-109,-27,-123,-91,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,105,110,112,117,116,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-24,-66,-109,-27,-123,-91,-28,-72,-128,-24,-95,-116,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,103,101,116,115,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-26,-106,-121,-28,-69,-74,-27,-80,-66,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,101,111,102,40,116,104,105,115,46,70,73,76,69,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-27,-82,-102,-28,-67,-115,40,105,44,115,112,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,115,101,101,107,40,116,104,105,115,46,70,73,76,69,44,105,44,115,112,41,10,
32,32,32,32,59,10,
32,32,32,32,100,101,102,32,116,104,105,115,46,-27,-67,-109,-27,-119,-115,-28,-67,-115,-25,-67,-82,40,41,58,10,
32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,102,116,101,108,108,40,116,104,105,115,46,70,73,76,69,41,32,32,32,32,10,
32,32,32,32,59,10,
10,
32,32,32,32,114,101,116,117,114,110,32,116,104,105,115,32,32,32,32,10,
59,10,
0};
#endif
void ElsLib_stdfile_libinit(els_VmObj *vm){
	vm_register(vm,"fputc",ELSAPI_stdfile_fputc);
	vm_register(vm,"ftell",ELSAPI_stdfile_ftell);
	vm_register(vm,"rewind",ELSAPI_stdfile_rewind);
	vm_register(vm,"feof",ELSAPI_stdfile_feof);
	vm_register(vm,"finput",ELSAPI_stdfile_finput);
	vm_register(vm,"fgets",ELSAPI_stdfile_fgets);
	vm_register(vm,"fputs",ELSAPI_stdfile_fputs);
	vm_register(vm,"fopen",ELSAPI_stdfile_fopen);
	vm_register(vm,"fclose",ELSAPI_stdfile_fclose);
	vm_register(vm,"fseek",ELSAPI_stdfile_fseek);
	vm_register(vm,"fgetc",ELSAPI_stdfile_fgetc);
	#ifdef ELS_CONF_TOKEN_EN
		vm_dostring(vm,LibScript);
	#endif
	#ifdef ELS_CONF_TOKEN_CN
		vm_dostring(vm,LibScript_cn);
	#endif
};
